name: Add Pull Requests to PR review project

on:
  pull_request:
    types:
      - opened

jobs:
  add-to-project:
    runs-on: ubuntu-latest

    steps:
    - name: Check if actor is an organization member
      id: check-membership
      run: |
        if [[ "${{ github.actor }}" == "mindsdb/"* ]]; then
          echo "::set-output name=isOrgMember::true"
        else
          echo "::set-output name=isOrgMember::false"
        fi
      shell: bash

    - name: Add issue to project
      if: steps.check-membership.outputs.isOrgMember == 'true'
      uses: actions/add-to-project@v0.5.0
      with:
        project-url: https://github.com/orgs/mindsdb/projects/65
        github-token: ${{ secrets.ADD_TO_PR }}
